<?php
declare (strict_types=1);

namespace Plugin\Alarm\Model;

use Mine\MineModel;

class RdAlarmWork extends MineModel
{
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_alarm_work';
    
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'id', 'title', 'content', 'status', 'stand_id', 'user_id', 'type', 'expire_times', 'expire_at', 'priority', 'related_type', 'related_id', 'extra', 'created_by', 'updated_by', 'created_at', 'updated_at'
    ];
    
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'id' => 'integer',
        'title' => 'string',
        'content' => 'string',
        'status' => 'integer',
        'stand_id' => 'integer',
        'user_id' => 'integer',
        'type' => 'integer',
        'expire_times' => 'integer',
        'expire_at' => 'datetime',
        'priority' => 'integer',
        'related_type' => 'integer',
        'related_id' => 'integer',
        'extra' => 'array',
        'created_by' => 'integer',
        'updated_by' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
    ];

    public function handle()
    {
        return $this->hasMany(RdAlarmHandleRecord::class, 'work_id', 'id');
    }
}

enum AlarmWorkStatus: int
{
    case Pending = 1;
    case Handle = 2;
    case Review = 3;
    case Complete = 4;
    case Close = 5;
}